package com.cntcdt.api.db.dao;

import java.util.List;

import com.cntcdt.api.db.dao.base.ConsociationCompanyMonthSumDaoBase;
import com.cntcdt.api.db.model.ConsociationCompanyMonthSumModel;

/**
 * 这是cdt_consociation_company_month_sum的Dao实现类
 */
public class ConsociationCompanyMonthSumDao extends ConsociationCompanyMonthSumDaoBase   {
    /**
     * ConsociationCompanyMonthSumDao对象
     */
    private static ConsociationCompanyMonthSumDao instance = new ConsociationCompanyMonthSumDao();

    /**
     * 默认构造方法
     */
    private ConsociationCompanyMonthSumDao() {
    }

    /**
     * 获得对象实例
     */
    public static ConsociationCompanyMonthSumDao getInstance() { 
         return instance;
    } 
    
    /**
     * 分页查询
     * @param id id
     * @return model
     */
    public List<ConsociationCompanyMonthSumModel> findBySortTime(String consociationCompanyId, long sortTime) {
        String sql = "SELECT id,SUM(borrowUserSum) as borrowUserSum,SUM(borrowCDBSum) as borrowCDBSum,SUM(newUserSum) as newUserSum,SUM(borrowRentSum) as borrowRentSum,SUM(sellLineMoneySum) as sellLineMoneySum,addTime,updateTime,consociationCompanyId,sortTime,SUM(sellCDBSum) as sellCDBSum,SUM(sellLineNum) as sellLineNum,isSettleAccounts FROM " + TABLE + " WHERE consociationCompanyId in ("+consociationCompanyId+") and sortTime < ? GROUP BY addTime order by sortTime desc limit 20";
       Object[] paramObjs = {sortTime};
       List<ConsociationCompanyMonthSumModel > modelList = this.queryModelList(sql, paramObjs);
       return modelList;
   } 

}
